package concurrent.unsafe;

import sun.misc.Unsafe;
import sun.reflect.Reflection;

import java.lang.reflect.Field;
import java.lang.reflect.Type;

/**
 * \* User: Administrator
 * <p>
 * \* Date: 2020/11/25
 * <p>
 * \* Time: 16:33
 * <p>
 * \* Description:
 * \
 */
public class UnsafeDemo {

//    private static Unsafe unsafe = Unsafe.getUnsafe();

    private static void getUnsafe() throws NoSuchFieldException, IllegalAccessException {
        Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe");
        String name = theUnsafe.getName();
        Type genericType = theUnsafe.getGenericType();
        theUnsafe.setAccessible(true);
        Unsafe o = (Unsafe) theUnsafe.get(null);
        // unsafe.storeFence();
    }

    public static void main(String[] args) throws NoSuchFieldException, IllegalAccessException {
        getUnsafe();
    }
}
